
$(function() {
	$("input[name$='_c']").css("width", 100);
	
	$("#login").dialog({
		width: 360,
		height: 180,
		resizable: false,
		draggable: false, 
		autoOpen: true
	});

	$('#login').dialog('option', 'title', '景荣办公系统');
});

function login() {
	$("#login").dialog('open');
}

function dialog_forget_(url, title, xy) {
	$('#dialog_edit').dialog('option', 'buttons', {
		"关闭": function() {
			$(this).dialog("close");
		},

		"提交": function() {
			var form = $("#form_edit")[0];

			var body = { };
			body.username = form.username.value;
			
			if (body.username == null || body.username == '') {
				alert("请输入员工姓名！");
				return false;
			}

			if (!confirm("确认是否提交？")) {
				return false;
			}

			$.post('emp.php?do=User.ajax_forgetPost', body, function(data) {
				var a = $.evalJSON(data);
				if (a.status == 2 || a.status == 1) {
					$('#dialog_edit').dialog("close");
				}
				
				alert(a.message);
			});
		}
	});

	dialog_edit(url, title, xy);
}

function login() {
	var body = $('#form_login').formSerialize();
	// alert(body);
	$.getJSON('/t/portal/?do=User.exist', body, function(json) {
		// alert($.toJSON(json));
		
		if (json.code == 0) {
			alert("用户名不存在，请重新输入！");
			return false;
		}
		
		if (json.data.status == 3) {
			alert("用户名已禁用，请联系管理员！");
			return false;
		}
		
		if (json.data.password == false) {
			alert("用户密码不对，请重新输入！");
			return false;
		}
		
		window.open('?do=Admin.loginPost&'+body, '_self');
		// alert("OK");
	});	
}
